<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="UTF-8">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/font-awesome.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/main.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/carousel.css">
    <style>
        .tree li {
            list-style-type: none;
            cursor: pointer;
        }

        table tbody tr:nth-child(odd) {
            background: #F4F4F4;
        }

        table tbody td:nth-child(even) {
            color: #C00;
        }
    </style>
</head>

<body>
<div class="navbar-wrapper ">
    <%--动态导入另一个jsp页面，作用：将公共使用的部分提取出来，然后使用动态导入
              动态导入是不会导入include页面的编译指令的，而是仅仅将被导入页面的body内容插入本页面。--%>
    <jsp:include page="admin-header.jsp"></jsp:include>
</div>
<div class="container-fluid">
    <div class="row">
        <%--动态导入另一个jsp页面，作用：将公共使用的部分提取出来，然后使用动态导入
                  动态导入是不会导入include页面的编译指令的，而是仅仅将被导入页面的body内容插入本页面。--%>
        <jsp:include page="admin-left.jsp"></jsp:include>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="glyphicon glyphicon-th"></i> 报修状态设置</h3>
                </div>
                <div class="panel-body">
                    <form id="setStatuForm" class="form-horizontal"
                          role="form">
                        <div class="form-group">

                            <input style="display: none" id="orderId" name="orderId" value="${tbOrder.orderId}">
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">报修状态</label>
                            <div class="col-sm-8">
                                <select class="form-control" id="statu" name="statu">
                                    <option value="处理中">处理中</option>
                                    <option value="驳回">驳回</option>
                                    <option value="已维修">已维修</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">常见问题：</label>
                            <div class="col-sm-8">
                                <button id="wwx" type="button" class="btn btn-default">无需维修</button>
                                <button id="clz" type="button" class="btn btn-warning">处理中</button>
                                <button id="wxwc" type="button" class="btn btn-success">维修完成</button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">描述：</label>
                            <div class="col-sm-8">
                                     <textarea name="statuDesc" rows="4" cols="20" id="statuDesc" class="form-control"
                                               style="color:#2E6DA4;font-size:18px;">
                </textarea>
                                <p class="help-block">待处理：着手解决待处理的报修申请时，请将报修申请设置为【处理中】，告知申请人报修已开始处理。<br/>
                                    处理中：处理中的报修如果完成，请设置维修完成，报修人可以评价维修完成的申请</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" id="btnSubmit" class="btn btn-primary tooltip-show"
                                        data-toggle="tooltip">保存设置
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="${pageContext.request.contextPath}/resources/jquery/jquery-2.1.1.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/resources/script/docs.min.js"></script>
<script type="text/javascript">
    $(function () {

        $(".list-group-item").click(function () {
            if ($(this).find("ul")) {
                $(this).toggleClass("tree-closed");
                if ($(this).hasClass("tree-closed")) {
                    $("ul", this).hide("fast");
                } else {
                    $("ul", this).show("fast");
                }
            }
        });
        $("#setStatuForm").on('click', '.btn-default', function () {
            console.log(11111111111111);
            $("#statuDesc").val('该报修申请无需维修。');
        });
        $("#setStatuForm").on('click', '.btn-warning', function () {
            console.log(2222222222);
            $("#statuDesc").val('已在处理该报修申请。');
        });
        $("#setStatuForm").on('click', '.btn-success', function () {
            console.log(33333333333);
            $("#statuDesc").val('报修申请已完成维修。');
        });

    });
    /*报修状态设置*/
    $("#setStatuForm").on('click', '.btn-primary', function () {
        var orderId = $('#orderId').val();
        var statu = $('#statu').val();
        var statuDesc = $('#statuDesc').val();
        //alert(orderId + "---" + statu + "---" + statuDesc);
        if (confirm("请确认操作")) {
            $.ajax({
                url: '/tbOrder/updateStatu',
                data: {
                    orderId: orderId,
                    statu: statu,
                    statuDesc: statuDesc
                },
                type: 'POST',
                dataType: 'json',
                success: function (data) {
                    if (data.flag) {
                        alert(data.msg);
                        location.replace("/tbOrder/searchOrders")
                    } else {
                        alert(data.msg);
                    }
                }
            });
        } else {
            location.replace("/tbOrder/searchOrders")
        }
    });

</script>
</body>
</html>
